<?php

namespace App;

use App\Api\Account\Models\UserAccount;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Zizaco\Entrust\Traits\EntrustUserTrait;


class User extends Authenticatable
{
    use EntrustUserTrait;
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name', 'email', 'mobile', 'rebate_mobile', 'password', 'data', 'wechat_id', 'weibo_id', 'api_token',//'wechat_at',
        'real_name', 'address', 'description', 'status', 'oauth_id', 'balance_threshold', 'credit',
        'name', 'email', 'password',
        'head_img',
        'sex',
        'level',
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token', 'email'
    ];

    public function operatorAccounts()
    {
        return $this->belongsToMany('App\Api\O2o\Models\OperatorAccount', 'users_operator_account', 'user_id', 'operator_account_id');
    }

    /**
     * Get the comments for the blog post.
     */
    public function openIds()
    {
        return $this->hasMany('\App\Api\Auth\Models\UserOpenId');
    }

    public function account()
    {
        return $this->hasOne(UserAccount::class);
    }

    static $sex = [
        '1' => '男',
        '2' => '女',
    ];

    static $cert_status = [
        '100' => '待审核',
        '200' => '审核通过',
        '-100' => '审核不通过',
    ];
}
